package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceAction;
import com.ruoyi.service.service.IServiceActionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 动作信息维护表Controller
 * 
 * @author ZDL
 * @date 2024-12-25
 */
@RestController
@RequestMapping("/service/action")
public class ServiceActionController extends BaseController
{
    @Autowired
    private IServiceActionService serviceActionService;

    /**
     * 查询动作信息维护表列表
     */
    @PreAuthorize("@ss.hasPermi('service:action:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceAction serviceAction)
    {
        startPage();
        List<ServiceAction> list = serviceActionService.selectServiceActionList(serviceAction);
        return getDataTable(list);
    }

    /**
     * 导出动作信息维护表列表
     */
    @PreAuthorize("@ss.hasPermi('service:action:export')")
    @Log(title = "动作信息维护表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceAction serviceAction)
    {
        List<ServiceAction> list = serviceActionService.selectServiceActionList(serviceAction);
        ExcelUtil<ServiceAction> util = new ExcelUtil<ServiceAction>(ServiceAction.class);
        util.exportExcel(response, list, "动作信息维护表数据");
    }

    /**
     * 获取动作信息维护表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:action:query')")
    @GetMapping(value = "/{actionId}")
    public AjaxResult getInfo(@PathVariable("actionId") Long actionId)
    {
        return success(serviceActionService.selectServiceActionByActionId(actionId));
    }

    /**
     * 新增动作信息维护表
     */
    @PreAuthorize("@ss.hasPermi('service:action:add')")
    @Log(title = "动作信息维护表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceAction serviceAction)
    {
        return toAjax(serviceActionService.insertServiceAction(serviceAction));
    }

    /**
     * 修改动作信息维护表
     */
    @PreAuthorize("@ss.hasPermi('service:action:edit')")
    @Log(title = "动作信息维护表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceAction serviceAction)
    {
        return toAjax(serviceActionService.updateServiceAction(serviceAction));
    }

    /**
     * 删除动作信息维护表
     */
    @PreAuthorize("@ss.hasPermi('service:action:remove')")
    @Log(title = "动作信息维护表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{actionIds}")
    public AjaxResult remove(@PathVariable Long[] actionIds)
    {
        return toAjax(serviceActionService.deleteServiceActionByActionIds(actionIds));
    }
}
